from playwright.sync_api import sync_playwright

def run(playwright):
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()

    # Open new page
    page = context.new_page()

    # Go to https://passport.lessonplan.cn/?returnURL=www.lessonplan.cn/
    page.goto("https://passport.lessonplan.cn/?returnURL=www.lessonplan.cn/")

    # Click [placeholder="电话 / 电子邮箱"]
    page.click("[placeholder=\"电话 / 电子邮箱\"]")

    # Fill [placeholder="电话 / 电子邮箱"]
    page.fill("[placeholder=\"电话 / 电子邮箱\"]", "sunwu")

    # Press Tab
    page.press("[placeholder=\"电话 / 电子邮箱\"]", "Tab")

    # Fill [placeholder="密码"]
    page.fill("[placeholder=\"密码\"]", "sunwu123")

    # Click text=登 录
    page.click("text=登 录")

    # Go to https://www.lessonplan.cn/?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyR3VpZCI6ImYyNjYwZWNhLTZkNDctMTZjZC01Y2ZlLTQ0NjYyZjVkNzVkMiIsInR5cGUiOiJ0ZWFjaGVyIiwiaWF0IjoxNjMzOTU5MDk4LCJleHAiOjE2MzM5OTUwOTh9.LvZ1OHkkdvvnfkbG74ngrOnnVK8ogigHud-hpqvcBy8
    page.goto("https://www.lessonplan.cn/?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyR3VpZCI6ImYyNjYwZWNhLTZkNDctMTZjZC01Y2ZlLTQ0NjYyZjVkNzVkMiIsInR5cGUiOiJ0ZWFjaGVyIiwiaWF0IjoxNjMzOTU5MDk4LCJleHAiOjE2MzM5OTUwOTh9.LvZ1OHkkdvvnfkbG74ngrOnnVK8ogigHud-hpqvcBy8")

    # Go to https://www.lessonplan.cn/main?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyR3VpZCI6ImYyNjYwZWNhLTZkNDctMTZjZC01Y2ZlLTQ0NjYyZjVkNzVkMiIsInR5cGUiOiJ0ZWFjaGVyIiwiaWF0IjoxNjMzOTU5MDk4LCJleHAiOjE2MzM5OTUwOTh9.LvZ1OHkkdvvnfkbG74ngrOnnVK8ogigHud-hpqvcBy8
    page.goto("https://www.lessonplan.cn/main?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyR3VpZCI6ImYyNjYwZWNhLTZkNDctMTZjZC01Y2ZlLTQ0NjYyZjVkNzVkMiIsInR5cGUiOiJ0ZWFjaGVyIiwiaWF0IjoxNjMzOTU5MDk4LCJleHAiOjE2MzM5OTUwOTh9.LvZ1OHkkdvvnfkbG74ngrOnnVK8ogigHud-hpqvcBy8")

    # Go to https://www.lessonplan.cn/main/home/myPacket/packetFile?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyR3VpZCI6ImYyNjYwZWNhLTZkNDctMTZjZC01Y2ZlLTQ0NjYyZjVkNzVkMiIsInR5cGUiOiJ0ZWFjaGVyIiwiaWF0IjoxNjMzOTU5MDk4LCJleHAiOjE2MzM5OTUwOTh9.LvZ1OHkkdvvnfkbG74ngrOnnVK8ogigHud-hpqvcBy8
    page.goto("https://www.lessonplan.cn/main/home/myPacket/packetFile?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyR3VpZCI6ImYyNjYwZWNhLTZkNDctMTZjZC01Y2ZlLTQ0NjYyZjVkNzVkMiIsInR5cGUiOiJ0ZWFjaGVyIiwiaWF0IjoxNjMzOTU5MDk4LCJleHAiOjE2MzM5OTUwOTh9.LvZ1OHkkdvvnfkbG74ngrOnnVK8ogigHud-hpqvcBy8")

    # Click text=我的班级
    page.click("text=我的班级")
    # assert page.url == "https://www.lessonplan.cn/main/home/roster"

    # Go to https://www.lessonplan.cn/main/home/roster
    page.goto("https://www.lessonplan.cn/main/home/roster")

    # Go to https://www.lessonplan.cn/main/home/roster/myroster
    page.goto("https://www.lessonplan.cn/main/home/roster/myroster")

    # Close page
    page.close()

    # ---------------------
    context.close()
    browser.close()

with sync_playwright() as playwright:
    run(playwright)